package com.zyh.system.supermark1.controller;

import com.zyh.system.supermark1.dao.impl.BuyCarDaoImpl;
import com.zyh.system.supermark1.dao.impl.GoodsDaoImpl;
import com.zyh.system.supermark1.domain.BuyCar;
import com.zyh.system.supermark1.domain.Goods;
import com.zyh.system.supermark1.domain.User;
import com.zyh.system.supermark1.service.impl.BuyCarServiceImpl;
import com.zyh.system.supermark1.service.impl.GoodsServiceImpl;

import java.util.LinkedList;
import java.util.Scanner;

public class BuyIndex {
    public static final Scanner INPUT = new Scanner(System.in);
    public static final LinkedList<Goods> GOODS_LIST = GoodsDaoImpl.GOODS_LIST;
    public static final LinkedList<BuyCar> CAR_LIST = BuyCarDaoImpl.CAR_LIST;
    public static final GoodsServiceImpl serviceImpl = new GoodsServiceImpl();
    public static final BuyCarServiceImpl carServiceImpl = new BuyCarServiceImpl();
    public static final UserIndex userIndex = new UserIndex();


    public void buyIndex(User user1) {
        while (true) {
            System.out.println("*********************电器商城********************************");
            System.out.println("                    1.商品购买                               ");
            System.out.println("                    2.我的购物车                             ");
            System.out.println("                    3.个人信息                               ");
            System.out.println("                    4.注销                                  ");
            System.out.println("*********************电器商城********************************");
            System.out.println("请输入菜单：");
            int choice = INPUT.nextInt();
            switch (choice) {
                case 1://1.商品购买
                    serviceImpl.shopping(GOODS_LIST);
                    break;
                case 2://2.我的购物车
                    carServiceImpl.showBuyCar(CAR_LIST);
                    break;
                case 3://3.个人信息
                    carServiceImpl.showUserInfo(user1);
                    break;
                default://4.注销
                    System.out.println("注销成功");
                    userIndex.userIndex();
            }
        }
    }
}
